﻿using MediatR;
using SystemLYH.API.Application.Command.ReservoirCommand;
using SystemLYH.Domain;
using SystemLYH.Infrstructre.Interface;

namespace SystemLYH.API.Application.Handlers.ReservoirHandlers
{
    public class ReservoirUpdateHandlers : IRequestHandler<ReservoirUpdateCommand, int>
    {
        protected readonly IReservoirRepository _reservoirRepository;
        /// <summary>
        /// 库区构造函数
        /// </summary>
        /// <param name="reservoirRepository"></param>
        public ReservoirUpdateHandlers(IReservoirRepository reservoirRepository)
        {
            _reservoirRepository = reservoirRepository;
        }
        public async Task<int> Handle(ReservoirUpdateCommand request, CancellationToken cancellationToken)
        {
            return await _reservoirRepository.UpdateAsync(new Reservoir()
            {
                ReservoirId = request.ReservoirId,
                ReservoirName = request.ReservoirName,
                ReservoirNumber = request.ReservoirNumber,
                ReservoirArea = request.ReservoirArea,
                ReservoirRemark = request.ReservoirRemark,
                WarehouseID = request.WarehouseID,
                IsDelReservoir = request.IsDelReservoir,
                AddName = request.AddName,
                AddTime = request.AddTime,
                UpdateName = request.UpdateName,
                UpdateTime = request.UpdateTime,
            });
        }
    }
}
